package com.lichhao.test;

import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.lichhao.common.model.BaseBean;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-config.xml" })
public abstract class SpringJunit4TestSupport<T extends BaseBean> {

	@Autowired
	protected MongoTemplate mongoTemplate;

	@Before
	public void init() {
		mongoTemplate.dropCollection(getBeanClass());
	}

	@After
	public void destroy() {
		mongoTemplate.dropCollection(getBeanClass());
	}

	protected abstract Class<T> getBeanClass();
}
